class Props extends EditableObject {
  /**
   * 道具sprite实例
   *
   * @type {PIXI.Sprite}
   * @memberof Props
   */
  props;

  key;

  constructor(app, propsInfo) {
    super(app);
    this.propsInfo = propsInfo;
    this.create();
    this.key = getRandomId();
  }

  /**
   * 创建一个道具
   *
   * @private
   * @memberof Props
   */
  create() {
    const { name, url, width, height } = this.propsInfo;
    const texture = getTextureFromCache(this.app, name, url); // 优先从预加载缓存中取出
    const sprite = PIXI.Sprite.from(texture);

    // 设置宽高
    width && (sprite.width = width);
    height && (sprite.height = height);

    // 放在舞台中央
    sprite.anchor.set(0.5);
    sprite.x = this.app.screen.width / 2 + offsetList[addedNum++ % 3];
    sprite.y = this.app.screen.height / 2;

    this.app.stage.addChild(sprite);
    this.props = sprite;

    this.obj = sprite;
    this.initObjEditable();
    this.makeSpriteEditable();
  }
}
